{extend name="index/base" /}
{block name="menu"}


{load href="/static/index/js/jquery.min.js"}
<div class="tpl-content-wrapper">
    <div class="tpl-content-page-title">
       南柯 用户管理
    </div>
    <ol class="am-breadcrumb">
        <li><a href="#" class="am-icon-home">首页</a></li>
        <li><a href="#">用户管理</a></li>
        <li class="am-active">用户管理</li>
    </ol>
    <div class="tpl-portlet-components">
        <div class="portlet-title">
            <div class="caption font-green bold">
                <span class="am-icon-code">{$title}</span>
            </div>
            <div class="tpl-portlet-input tpl-fz-ml">
                <div class="portlet-input input-small input-inline">
                </div>
            </div>


        </div>
        <div class="tpl-block">
            <div class="am-g">
                <div class="am-u-sm-12 am-u-md-6">
                    <div class="am-btn-toolbar">
                        <div class="am-btn-group am-btn-group-xs">
                            <a type="button" class="am-btn am-btn-default am-btn-success" href="{:url('index/user/create')}"><span class="am-icon-plus"></span> 新增</a>
                        </div>
                    </div>
                </div>
                <div class="am-u-sm-12 am-u-md-3">
                    <div class="am-form-group">

                    </div>
                </div>
                <div class="am-u-sm-12 am-u-md-3">
                    <div class="am-input-group am-input-group-sm">

                    </div>
                </div>
            </div>
            <div class="am-g">
                <div class="am-u-sm-12">
                    <form class="am-form">
                        <table class="am-table am-table-striped am-table-hover table-main">
                            <thead>

                            <!--content start-->
                            <tr>
                                <th class="table-check"><input type="checkbox" class="tpl-table-fz-check"></th>
                                <th class="table-id">ID</th>
                                <th class="table-title">用户名</th>
                                <!--<th class="table-type">站点名</th>-->
                                <th class="table-author am-hide-sm-only">账号</th>
                                <!--<th class="table-date am-hide-sm-only">到期时间</th>-->
                                <!--<th class="table-set">IP地址</th>-->
                            </tr>
                            <!--content stop-->
                            </thead>
                            <tbody>

                            {volist name="list" id="vo"}
                            <tr>
                                <td><input type="checkbox"></td>
                                <td>{$vo.id}</td>
                                <td><a href="#">{$vo.name}</a></td>
                                <td class="am-hide-sm-only">{$vo.username}</td>

                                <td>
                                    <div class="am-btn-toolbar">
                                        <div class="am-btn-group am-btn-group-xs">
                                            <a class="am-btn am-btn-default am-btn-xs am-text-secondary" href="{:url('index/user/edit',['id'=>$vo.id])}"><span class="am-icon-pencil-square-o"></span> 编辑</a>

                                            <a  href="{:url('index/user/qx',['id'=>$vo.id])}"  class="am-btn am-btn-default am-btn-xs am-hide-sm-only"><span class="am-icon-copy"></span> 权限管理</a>



                                            <button type="button" class=" bbtn  btn am-btn am-btn-default am-btn-xs am-text-secondary " data-toggle="modal" data-target="#myModal" data-t="{$vo.id}">
                                                删除
                                            </button>


                                        </div>
                                    </div>
                                </td>
                            </tr>
                            {/volist}
                            </tbody>
                        </table>
                        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                            <div class="modal-dialog" role="document">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button type="button" class="close" id="bbb" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
                                    </div>
                                    <div class="modal-body">
                                        确认要删除吗(不可恢复)?
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-default" id="ccc" data-dismiss="modal">算了,不用了</button>
                                        <button type="button" id="aaaa" class="cbtn btn btn-primary"   style="color: #000;">怕什么,删了</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="am-cf">

                        </div>
                        <hr>

                    </form>
                </div>

            </div>
        </div>
        <div class="tpl-alert"></div>



    </div>

</div>


<script>

    $('.bbtn').click(function () {
        data = $(this).attr('data-t');
        obj = $(this).parents('tr');


//        var sure = document.getElementsByClassName('cbtn')[0];
//        console.log(sure);

//        sure.addEventListener('click',function(data,$this){
//            console.log(data);
//            $.ajax({
//                type:'delete',
//                url:'gl/'+data,
//                synsc:'true',
//                success:function(aa){
//                    if(aa){
//                        $this.remove();
//                        alert('删除成功');
//                    }
//                },
//                error:function(){
//
//                    alert('删除失败');
//                }
//            });
//        })
    });

    $('#aaaa').click(function () {
//        console.log(data);
        $.ajax({
                type:'delete',
                url:'user/'+data,
                success:function(aa){
                    console.log(aa);
                    if(aa){
                        obj.remove();
//                        $('#myModal').hide();
                        alert('删除成功');
                        $('#ccc').click();

                    }else{
//                        $('#myModal').hide();
                        alert('删除失败');
                        $('#ccc').click();
                    }
                },
                error:function(){
                    $('#myModal').hide();
                    alert('删除失败1');
                }
            });
    })

</script>



<script src="/static/home/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="/static/home/css/bootstrap.min.css">



{/block}
